﻿#ifndef INSTRUCTIONLOOP
#define INSTRUCTIONLOOP
#include "ScriptInstruction.h"

class InstructionLoop :public ScriptInstruction
{
  Q_OBJECT
private:
  ScriptRunner* scriptRunner = Q_NULLPTR;
  int scriptIndex = 0;
  int loopCount = 0;
public:
  InstructionLoop(int scriptIndex, int loopCount)
  {
    scriptRunner = ScriptInstruction::getScriptRunner();
    this->scriptIndex = scriptIndex;
    this->loopCount = loopCount;
    instructionFlag = MetaInstruction_Loop;
  }
  ~InstructionLoop()
  {}
public:
  void run()override
  {
    scriptRunner->newLoop(scriptIndex, loopCount);
    scriptRunner->scriptWaitAndRun(scriptRunner->getInterval_instruction());
  }
  QVector<float> getDataForSaving()override
  {
    QVector<float> savingData;
    savingData.append(instructionFlag);
    savingData.append(scriptIndex);
    savingData.append(loopCount);
    return savingData;
  }
};
#endif
